<?php
class admin_intro extends CI_Controller {
	protected $_page_name = "admin_intro";
	protected $_page_id = 'ul_postcontainer';
	protected $data;
	function  __construct()  {
		$this->_initdata();
	}
	
	function _initdata()
	{
		parent::__construct();
		session_start();
		$this->load->model('Adminmodel');
		$this->load->helper('url');
		$this->_check_admin_login();	
		$this->data['base_url'] = $this->config->item('base_url');
	}	
	
	function _check_admin_login()
	{
		if ($this->Adminmodel->_check_login(SESSION_ADMINUSERNAME) == false)
		{
			$base_url=$this->config->item('base_url');
			redirect($base_url.'admin_login', 'location', 301);
		}		
	}
	
	//default page (tim_kiem)
	function index() {
		echo "Trang n&agrave;y s&#7869; b&#7893; sung sau.";exit;
		$iCurPage=1;
		$iCurPage = $this->uri->segment(2);
		$iRow_Count=0;
		@$limit=PAGESIZE;
		$start=$iCurPage*PAGESIZE-PAGESIZE;
		if(!($start > 0)) { 
		$start = 0;
		}
		$eu = ($start - 0); 
		if(!$limit > 0 ){ 
		$limit = 20; 
		}                             
		list($iRow_Count, $this->data['aVideo']) = $this->phapan->_get_video_list($eu, $limit);	
		$this->data['paging'] = $this->paging($iCurPage,ceil($iRow_Count/PAGESIZE),$this->config->item('base_url').$this->_page_name,$iRow_Count);
		$this->data['cur_page'] = $iCurPage;
		$this->data['webpage_id'] = $webpage_id;
		$this->data['page_title'] = "Page Title";
		//$this->data['image_type_list'] = $this->phapan->_get_image_type_db();			
		$this->showadmin($this->data);
	}		
	
	function edit()
	{
		if(!empty($_POST) && $_POST['isPost']==1) {
			$id =  $_POST['h_id'];
			if ($id != "")
			{
				$this->data['txt_password'] =  $_POST['txt_password'];
				$this->updateintro($_POST);	
			}
			else
			{
				
			}
			//thong bao & redirect page
			$this->session->set_userdata("msg", "Bạn đã cập nhật thành công.");
			$this->load->helper('url');
			echo "<script>window.location='".$this->data['base_url'].'admin_intro/edit/'.$id."'</script>";				
		}		
		else
		{
			//begin show message update
			$data["msg"]=$this->session->userdata("msg");
			$this->session->set_userdata("msg","");
			//end   show message update
			$data["page_name"]="admin_intro_edit";
			$data['id'] = $this->uri->segment(3);
			$data['webpage_id'] = 1;
			$data['base_url']=$this->config->item('base_url');
			$data['page_id'] = "ul_postcontainer";	
			$data['is_show_action'] = "";
			$data['page_title'] = "THÔNG TIN MẬT KHẨU";
			$data['link_page_name'] = "link_page_name";
			$data['previous_id'] = "1";
			$data['website_name'] = WEBSITE_NAME;
			$this->load->view('common/common_view_admin',$data);					
		}
	}
	
	function updateintro($data){
		$id =  $data['h_id'];
		$data = array(
						'password'  => md5($data['txt_password'])
					 );
					 
		$db = $this->load->database('default', TRUE);
		$query = $db->where('user_id', $id);
		$aRows = $query->update('be_user', $data);
	}		
	
}
?>